/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package concurrencia;

import java.util.Queue;
import java.util.concurrent.LinkedBlockingQueue;

/**
 *
 * @author eltorre
 */
public class WSDLProvider extends Thread{
    
    private WSDLProvider() {};
    
    private static WSDLProvider instance = null;
    
    public static WSDLProvider getInstance()
    {
        if (instance == null)
            instance = new WSDLProvider();
        return instance;
    }
    
    @Override
    public void run()
    {
         while (true)
         {
             if (requests.isEmpty())
             {
                 try
                 {
                    sleep(100);
                 }
                 catch (Exception ex)
                 {
                     
                 }
             }
             else
             {
                 while(!requests.isEmpty())
                 {
                     requests.remove().start();
                 }
             }
         }
    }
    
    
    
    
    public void issue(Request r)
    {
        requests.add(r);
    }
    
    Queue<Request> requests = new LinkedBlockingQueue<Request>();
}
